home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus Special 17 / AMIGAplus Sonderheft 17 (1999)(ICP)(DE)[!].iso / PD / Anwendungen / IxGuide / docs / ixclient_3.rexx < prev    next >
OS/2 REXX Batch file  |  1997-03-22  |  4KB  |  202 lines

  1. /* Sample arexx client program for iX-Guide   */
  2. /* How to make scrolling object which takes   */
  3. /* care of changing documents, screens ...    */
  4. /* NOTE: never write programs which perform   */
  5. /* some graphics operations for a long period */
  6. /* of time without using delay()              */
  7.  
  8. if ~show('l', "rexxsupport.library") then
  9.     addlib('rexxsupport.library',0,-30,0)
  10.  
  11. OPTIONS RESULTS
  12.  
  13. /*
  14. ** Every rexx client receives pointer to iXG window as the last argument
  15. ** in form 'iXW=<address>'. That is the window the rexx client was launched
  16. ** from. You always have to pass this pointer to ADDCLIENT !
  17. */
  18.  
  19. PARSE ARG 'iXW=' windowPTR .
  20.  
  21. /*
  22. ** Port name of every rexx client should be in the following form:
  23. ** "IXCL_anythingyouwant_windowPTR"
  24. */
  25.  
  26. portname = "IXCL_demoCL3_"
  27. portname = INSERT(windowPTR,portname,LENGTH(portname))
  28.  
  29. /************************************************************************/
  30.  
  31. if show('p',portname) then exit   /* we are already running */
  32.  
  33. ADDRESS IXGUIDE
  34.  
  35. /*
  36. ** Add this client to iX-Guide and pass received window pointer
  37. */
  38.  
  39. AddClient windowPTR
  40.  
  41. /************************************************************************/
  42.  
  43. txt.1 = '"    Scrolling text    "'
  44. txt.2 = '" -------------------- "'
  45. txt.3 = '"This is demo of Arexx "'
  46. txt.4 = '"  controled object.   "'
  47. txt.5 = '"  To stop scrolling   "'
  48. txt.6 = '"  press STOP button   "'
  49. txt.7 = '" and START button to  "'
  50. txt.8 = '"     start again      "'
  51. txt.9 = '" -------------------- "'
  52.  
  53. call openport(portname)
  54. setport portname MISC
  55. AllocRaster 2
  56. rp=result
  57. refresh rp
  58. SetABPen rp 1 0
  59.  
  60. OpenFont 'times.font' 18; f1 = result
  61. OpenFont 'topaz.font' 8;  f2 = result
  62. SetDrMd rp 0
  63.  
  64. shutdown=0
  65. flag=0
  66. stopscroll=0
  67. contscroll=0
  68. ypos = 120
  69. linecnt = 1
  70.  
  71. do until shutdown
  72.  call waitpkt(portname)
  73.  msg = getpkt(portname)
  74.  
  75.  if msg ~= '0000 0000'x then do
  76.   class = getarg(msg)
  77.   
  78.   if class='0000 0000'x then shutdown=1  /* pointer to window is NULL */
  79.   else if class=windowPTR then do        /* this is message from our window */
  80.   class = getarg(msg,1)
  81.   
  82.   if class = 'MISC' then do
  83.    a1 = getarg(msg,2)
  84.    
  85.    if a1 = 'QUIT' then shutdown=1
  86.    
  87.    if a1 = 'CLOSEWIN' then shutdown=1
  88.    
  89.    if a1 = 'LINKREQ' then do
  90.     a2 = getarg(msg,3)
  91.     if a2 = 'rx_start' then do
  92.      flag=1  /* we should start scrolling */    
  93.      stopscroll=0
  94.     end
  95.    end /*end if LINKREQ*/
  96.    
  97.    if (a1 = 'LINKOK') | (a1 = 'LINKFAILED') then
  98.     if contscroll then do
  99.      a2 = getarg(msg,3)
  100.      a3 = getarg(msg,4)
  101.      if (a2='iX-Guide.ixml') & (a3='arexx_demo') then do
  102.       flag=1
  103.       stopscroll=0
  104.       contscroll=0
  105.      end
  106.     end
  107.    
  108.    if (a1 = 'OLDSCREEN') | (a1 = 'NEWSCREEN') then shutdown=1
  109.     /*if contscroll then do
  110.       flag=1
  111.       stopscroll=0
  112.       contscroll=0
  113.     end*/
  114.  
  115.   end /*end if class==MISC*/
  116.   end
  117.   call reply(msg,0)
  118.  end /*end if msg*/
  119.  
  120. if flag=1 then do /* should we start scrolling? */
  121. do until stopscroll
  122.  call scroll()
  123.  call delay(1)
  124.  call checkinput()
  125. end /*end until stopscroll*/
  126. flag=0
  127. end /*end if flag==1*/
  128. end /*end until shutdown*/
  129.  
  130. /* clean up */
  131. CloseFont f1; CloseFont f2
  132. FreeRaster rp
  133. RemClient
  134. call closeport(portname)
  135. exit
  136.  
  137. checkinput:
  138.  cimsg = getpkt(portname)
  139.  do while cimsg ~= '0000 0000'x
  140.   ciclass = getarg(cimsg)
  141.   
  142.   if ciclass='0000 0000'x then shutdown=1  /* pointer to window is NULL */
  143.   else if ciclass=windowPTR then do        /* this is message from our window */
  144.   ciclass = getarg(msg,1)
  145.   
  146.   if ciclass = 'MISC' then do
  147.    cia1 = getarg(cimsg,2)
  148.    
  149.    if cia1 = 'QUIT' then do
  150.     stopscroll=1
  151.     shutdown=1
  152.    end
  153.  
  154.    if cia1 = 'CLOSEWIN' then do
  155.     stopscroll=1
  156.     shutdown=1
  157.    end
  158.    
  159.    if cia1 = 'LINKREQ' then do
  160.     stopscroll=1
  161.     cia2 = getarg(cimsg,3)
  162.     if cia2 ~= 'rx_stop' then contscroll=1
  163.     call reply(cimsg,0)
  164.     return 0
  165.    end
  166.    
  167.    if cia1 = 'ASKSCREEN' then do
  168.     stopscroll=1
  169.     contscroll=1
  170.     call reply(cimsg,0)
  171.     return 0
  172.    end
  173.  
  174.   end /*end if 'MISC'*/
  175.   end
  176.  call reply(cimsg,0)
  177.  cimsg = getpkt(portname)
  178.  end /*end do while cimsg*/
  179. return 0
  180.  
  181. scroll:
  182.  ypos = ypos - 1
  183.  if ypos<110 then do
  184.   ypos = 120
  185.   linecnt=linecnt+1
  186.   if linecnt>9 then linecnt=1
  187.  end
  188.  ScrollRaster rp 0 1 0 0 197 178
  189.  if linecnt=1 then SetABPen rp 2
  190.  else SetABPen rp 1
  191.  if linecnt=1 then do
  192.  SetFont rp f1
  193.  Move rp 30 ypos+2
  194.  Text rp txt.linecnt
  195.  end
  196.  else do
  197.  SetFont rp f2
  198.  Move rp 10 ypos
  199.  Text rp txt.linecnt
  200.  end
  201. return 0
  202.